home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2002 #3
/
Amiga Plus CD - 2002 - No. 03.iso
/
AmiSoft
/
Util
/
Misc
/
Lottery2002.lha
/
Lottery2002
/
Source
/
events.c
< prev
next >
Wrap
C/C++ Source or Header
|
2003-02-09
|
3KB
|
157 lines
/* events.c */
#include "includes.h"
#include "externals.h"
void events(struct MsgPort *AppPort, Object *object,
struct Gadget *gadgets[], struct Window *win)
{
BOOL done = FALSE;
ULONG wait, signal, app = (1L << AppPort->mp_SigBit);
ULONG result;
UWORD code;
/* Obtain the window wait signal mask.*/
GetAttr(WINDOW_SigMask, object, &signal);
/* Input Event Loop*/
while (!done)
{
wait = Wait( signal | app );
while ((result = RA_HandleInput(object, &code)) != WMHI_LASTMSG)
{
switch (result & WMHI_CLASSMASK)
{
case WMHI_CLOSEWINDOW:
win = NULL;
done = TRUE;
break;
case WMHI_GADGETUP:
done = handlegads(win, gadgets, code, (result & WMHI_GADGETMASK));
break;
case WMHI_GADGETHELP:
{
ULONG helpcode = (result & WMHI_GADGETMASK);
if((helpcode == 0) || (helpcode == 65535))
SetWindowTitles(win, (UBYTE *)-1, g_scrtitle);
else
handlehelp(win, helpcode);
}
break;
case WMHI_MENUPICK:
done = handlemenus(win, gadgets, object, (result & WMHI_MENUMASK));
break;
case WMHI_VANILLAKEY:
done = handlegads(win, gadgets, code, (result & WMHI_KEYMASK));
break;
case WMHI_ICONIFY:
RA_Iconify(object);
win = NULL;
break;
case WMHI_UNICONIFY:
win = (struct Window *) RA_OpenWindow(object);
if (win)
{
GetAttr(WINDOW_SigMask, object, &signal);
}
else
{
done = TRUE; // could not re-open window, Quit Lottery2002
}
break;
}
}
}
}
/* Handles Help events */
void handlehelp(struct Window *win, ULONG helpcode)
{
char *spkhlp = "Speak disabled, No narrator.device or translator.library =>V36.";
if(spk_flag)
spkhlp = "Speak the Lottery numbers, Wed 1st then Sat.";
{
char *helptext[] = {NULL,
g_scrtitle,
"Start generating random lottery numbers.",
spkhlp,
"Click here to Quit Lottery2002."};
SetWindowTitles(win, (UBYTE *)-1, helptext[helpcode - 12]);
}
}
/* Handles Menu events */
BOOL handlemenus(struct Window *win, struct Gadget *gads[],
Object *object,UWORD m_number)
{
BOOL done = FALSE;
UWORD menunum, itemnum, subnum;
struct MenuItem *item;
while((m_number != MENUNULL) && (!done))
{
item = ItemAddress(g_menustrip, m_number);
menunum = MENUNUM(m_number);
itemnum = ITEMNUM(m_number);
subnum = SUBNUM(m_number);
if(menunum == 0)
{
switch(itemnum)
{
case 0: // START
get_num(win, gads);
break;
case 1: // SPEAK
{
putbusy(win);
if(speaknums(wednums, 0))
speaknums(satnums, 1);
clearbusy(win);
}
break;
case 3: // ABOUT
{
char *abouttext[] = {
"\nLottery2000 V2.1 (OS3.5/9).\n\n"
"(c) T. Collier 2002. \n\n"
"Written in 'C' Using Dice 3.2 & StormC Pro 3.\n\n"
"Gadget Help is shown in the screen title bar.\n"};
putbusy(win);
requester("About Lottery 2002", *abouttext, g_okbutton);
clearbusy(win);
}
break;
case 4: // ICONIFY
RA_Iconify(object);
win = NULL;
break;
case 6: // QUIT
done = TRUE;
break;
}
}
m_number = item->NextSelect;
}
return(done);
}